package logic

import (
	"context"
	"month2/B/rpc_B/model/mysql"

	"month2/B/rpc_B/internal/svc"
	"month2/B/rpc_B/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserListLogic {
	return &UserListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserListLogic) UserList(in *user.UserListRequest) (*user.UserListResponse, error) {
	var user2 []*mysql.User2
	mysql.DB.Find(&user2)
	var userlist []*user.UserList
	for _, m := range user2 {
		list := user.UserList{
			Name:   m.Name,
			Tel:    m.Tel,
			Status: int64(m.Status),
		}
		userlist = append(userlist, &list)
	}
	return &user.UserListResponse{List: userlist}, nil
}
